<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Cache;

class MockFaceCacheCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'cache:face_mock {ids*}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Description:
     * Author: Sam
     * DateTime: 2019-03-21 18:03
     * @throws \Psr\SimpleCache\InvalidArgumentException
     */
    public function handle()
    {
        $ids = $this->argument('ids');
        foreach ($ids as $k => $v){
            $params = [
                'face_id'=>'mock_id_'.$v,
                'status'=>'mock_id_'.$v,
                'confidence'=>'mock_id_'.$v,
                'hand_cert'=>'mock_id_'.$v,
            ];
            Cache::delete("face_cache_{$v}");
            Cache::add("face_cache_{$v}",json_encode($params),60*24);
        }
        echo "done\n";
    }
}
